package com.bang.study.jvm.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * @Auther: Bang
 * @Date: 2019/9/29 21:29
 * @Description: java运行时常量池异常
 * @VM : -Xms20m -Xmx20m -XX:MetaspaceSize=10m -XX:MaxMetaspaceSize=10m
 * java1.8字符串常量池时存在堆内存,所以此方法会造成堆内存溢出
 *
 */
public class RuntimeConstantPoolOOM {

    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(1000 * 20);
        List<String> list = new ArrayList<>();
        for (int j = 0; j <10000000 ; j++) {
            list.add(String.valueOf(j).intern());
        }
    }
}
